<template>
  <el-dialog title="订单状态" :visible.sync="dialogVisible" width="1200px" :close-on-click-modal="false"  :modal-append-to-body="false" v-drag2anywhere>
    <el-form v-model="formData" label-width="80px">
      <el-row :gutter="20">
        <el-col :span="6">
          <el-form-item label="内部单号:">
            {{formData.ouid}}
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="外部单号:">
            {{formData.ordercode}}
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="订单渠道:">
            {{formData.platform}}
          </el-form-item>
        </el-col>

        <el-col :span="6">
          <el-form-item label="客户单位:">
            {{formData.clientname}}
          </el-form-item>
        </el-col>

        <el-col :span="6">
          <el-form-item label="订单总额:">
            ¥ {{parseFloat(formData.sum_order+"").toFixed(2)}}
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="收货信息:">
            {{formData.buyerinfo.buyer}}- {{formData.buyerinfo.mobile}}- {{formData.buyerinfo.address}}
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="业务员:">
            {{formData.saleman}}
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="合作商:">{{formData.supname}}</el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="所属账套:">{{formData.account}}</el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="6">
          <el-form-item label="订单状态:">
              <el-select v-model="status" placeholder="订单状态">
                <el-option label="正常" value="0"></el-option>
                <el-option label="取消" value="1"></el-option>
              </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="18">
            <el-form-item label="状态备注:">
              <el-input type="textarea" v-model="formData.statusmemo" rows="5" placeholder="订单状态备注"></el-input>
            </el-form-item>
        </el-col>
      </el-row>
    </el-form>

    <div slot="footer" class="dialog-footer">
    	<el-button size="medium" @click="dialogVisible=false">取消</el-button>
      <el-button type="primary" size="medium" @click="handleSave">保存状态</el-button>
    </div>

  </el-dialog>
</template>

<script>
  export default {
    data() {
      return {
        index:-1,
        formData:{
          status:-1,
          statusmemo:'',
          buyerinfo:{
            buyer:'',
            mobile:'',
            address:''
          }
        },
        status:-1,
        dialogVisible: false
      }
    },
    methods:{
      init(index,data){
          this.index=index;
          this.formData=data;
          this.status=this.formData.status;
      },
      handleSave(){
          var params={
            status:this.status,
            ouid:this.formData.ouid,
            statusmemo:this.formData.statusmemo
          }

          this.axios.post("/api/admin/order/update_status",params).then(res => {
            if (res.status == 200 && res.data.code == 1) {
                this.$message.success(res.data.msg);
                this.formData.status=this.status;
                this.$emit("updated",this.index,this.formData);
                this.dialogVisible=false;
            }else{
              this.$message.error(res.data.msg);
            }
          })



      }
    }
  }
</script>

<style>
</style>
